home *** CD-ROM | disk | FTP | other *** search
-
- /* Generated by Interface Builder */
-
- #import "PlayerUpView.h"
- #import <appkit/NXImage.h>
- #import <appkit/Control.h>
- #import <appkit/graphics.h>
- #import <dpsclient/psops.h> // PSxxx functions
-
- @implementation PlayerUpView
-
- - initFrame:(const NXRect *)frm // initialize instance
- {
- [super initFrame:frm];
- numUp = 0;
- pacs = [NXImage findImageNamed:"Pacs.tiff"];
- return self;
- }
-
- - drawSelf:(NXRect *)rects :(int)rectCount // standard rendering method
- {
- // It is assumed that this view is exactly 96x80 pixels,
- // which allows 6 pacs across and 5 pacs vertically.
- // for now, they're at stationary locations.
- int i;
- NXRect from;
- NXPoint pos;
-
- PSsetgray(0.666);
- NXRectFill(&bounds);
- NXSetRect(&from, 2 * PAC_SIZE, PAC_SIZE, PAC_SIZE, PAC_SIZE);
- if (!numUp) return self;
- for (i=0; i<=((numUp < 6) ? numUp - 1 : 5); i++) {
- // figure out where to draw the Pac and then composite it onto the view
- pos.x = (i % 3) * PAC_SIZE * 2 + PAC_SIZE / 2;
- pos.y = (i / 3) * PAC_SIZE * 2 + PAC_SIZE;
- [pacs composite:NX_SOVER fromRect:&from toPoint:&pos];
- }
- NXPing();
- return self;
- }
-
- - setNumUp:(int)num // draw all fruits up to level
- {
- if (numUp == num) return self;
- numUp = num;
- [self update];
- return self;
- }
-
- - incPacs // add another pac to the bunch
- {
- numUp++;
- [self update];
- return self;
- }
-
- - (int)pacs { return numUp; } // return # pacs left
-
- - (BOOL)nextPac // if pacs left, decrement # pacs and return YES.
- { // returns NO if no pacs left.
- if (numUp) {
- numUp--;
- [self update];
- return YES;
- }
- return NO;
- }
-
- @end
-